Skip to content

refactor: getPackageVersion fn cleanup#22941

Merged
benesjan merged 1 commit into
merge-train/fairiesfrom
jb/get-package-version-from-package-json
May 5, 2026
Merged

refactor: getPackageVersion fn cleanup#22941
benesjan merged 1 commit into
merge-train/fairiesfrom
jb/get-package-version-from-package-json

Conversation

@benesjan
Copy link
Copy Markdown
Contributor

@benesjan benesjan commented May 5, 2026

This other PR of mine was motivation for this because there we need to stamp aztec version into contract artifact and the current getPackageVersion was not helpful in that because it failed to resolve the actual version (e.g. v4.3.0-nightly.20260427 instead of v4.3.0). To workaround this I will no longer read the version from .release-please-manifest.json and will read it from package.json instead where the version is stamped during a release. If the code is not run from a release the version is simply populated with "dev" which seems better then returning undefined and forcing the callsites to deal with it.

Bothering Adam and Alex with a review here since you are the only people that seemed to have touched the function.

AI Summary

  • getPackageVersion previously read from .release-please-manifest.json, which holds the next stable target (currently 5.0.0) — not the actually-installed/built version. So nightlies and stable releases reported a stale version.
  • It now reads from the stdlib package.json (which release tooling stamps at publish time) and substitutes DEV_VERSION ('dev') for the 0.1.0 placeholder used in a monorepo checkout.
  • Return type narrowed from string | undefined to string, and the now-dead ?? '<fallback>' chains in callers (aztec-node, aztec CLI, cli-wallet, txe) are dropped.
  • warnIfAztecVersionMismatch gets an early return on DEV_VERSION so monorepo checkouts no longer spam warnings about every aztec-nr dep tag mismatch (previously it would compare against v5.0.0, now it would have compared against vdev — both wrong).

.release-please-manifest.json is left in place for now since release tooling may still consume it; removing it can be a separate change.

Context from #21382 review thread: https://github.com/AztecProtocol/aztec-packages/pull/21382/files#r3182335186

…lease manifest

The release-please manifest holds the *next* stable target rather than the
actually-installed/built version, so reads were stale for nightly and stable
releases. Read from the stdlib `package.json` (which release tooling stamps at
publish time) and substitute `DEV_VERSION` ('dev') for the `0.1.0` placeholder
used in monorepo checkouts.

Also narrows the return type from `string | undefined` to `string` and drops
the now-dead `?? '<fallback>'` chains in callers. `warnIfAztecVersionMismatch`
gets an early return on `DEV_VERSION` so monorepo checkouts no longer warn on
every aztec-nr dep.
@benesjan benesjan marked this pull request as ready for review May 5, 2026 09:38
@benesjan benesjan changed the title refactor: read package version from package.json instead of release-please manifest refactor: getPackageVersion fn cleanup May 5, 2026
@benesjan benesjan changed the title refactor: getPackageVersion fn cleanup refactor: getPackageVersion fn cleanup May 5, 2026
@benesjan benesjan requested review from alexghr and ludamad May 5, 2026 10:46
Copy link
Copy Markdown
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because we don't publish .release-please-manifest.json to npm? But in that case I would have expected the fallback to kick in.

@ludamad
Copy link
Copy Markdown
Collaborator

ludamad commented May 5, 2026

we're ok with this reporting 0.0.1 in dev copy?

@benesjan
Copy link
Copy Markdown
Contributor Author

benesjan commented May 5, 2026

Is it because we don't publish .release-please-manifest.json to npm? But in that case I would have expected the fallback to kick in.

@alexghr TBH I don't know but anyway it's unnecessary there as the version gets stamped to package.json of the stdlib package.

we're ok with this reporting 0.0.1 in dev copy?

@ludamad it's the other way round - if there is 0.0.1 then it means the version didn't get stamped in package.json which implies a local repo checkout.

I want this to return dev since I need to stamp something into contract artifact in that other PR of mine and dev seems nicer than 0.0.1.

@benesjan benesjan merged commit b819b71 into merge-train/fairies May 5, 2026
40 checks passed
@benesjan benesjan deleted the jb/get-package-version-from-package-json branch May 5, 2026 14:15
AztecBot pushed a commit that referenced this pull request May 5, 2026
[This other
PR](#22941) of mine
was motivation for this because there we need to stamp aztec version
into contract artifact and the current `getPackageVersion` was not
helpful in that because it failed to resolve the actual version (e.g.
`v4.3.0-nightly.20260427` instead of `v4.3.0`). To workaround this I
will no longer read the version from `.release-please-manifest.json` and
will read it from package.json instead where the version is stamped
during a release. If the code is not run from a release the version is
simply populated with "dev" which seems better then returning undefined
and forcing the callsites to deal with it.

Bothering Adam and Alex with a review here since you are the only people
that seemed to have touched the function.

## AI  Summary

- `getPackageVersion` previously read from
`.release-please-manifest.json`, which holds the *next* stable target
(currently `5.0.0`) — not the actually-installed/built version. So
nightlies and stable releases reported a stale version.
- It now reads from the stdlib `package.json` (which release tooling
stamps at publish time) and substitutes `DEV_VERSION` (`'dev'`) for the
`0.1.0` placeholder used in a monorepo checkout.
- Return type narrowed from `string | undefined` to `string`, and the
now-dead `?? '<fallback>'` chains in callers (`aztec-node`, `aztec` CLI,
`cli-wallet`, `txe`) are dropped.
- `warnIfAztecVersionMismatch` gets an early return on `DEV_VERSION` so
monorepo checkouts no longer spam warnings about every aztec-nr dep tag
mismatch (previously it would compare against `v5.0.0`, now it would
have compared against `vdev` — both wrong).

`.release-please-manifest.json` is left in place for now since release
tooling may still consume it; removing it can be a separate change.

Context from #21382 review thread:
https://github.com/AztecProtocol/aztec-packages/pull/21382/files#r3182335186
@AztecBot
Copy link
Copy Markdown
Collaborator

AztecBot commented May 5, 2026

✅ Successfully backported to backport-to-v4-next-staging #22924.

AztecBot added a commit that referenced this pull request May 5, 2026
BEGIN_COMMIT_OVERRIDE
docs: add map and state variable docs  (#22824)
fix: e2e compat should not fail for contracts added after legacy stables
(#22900)
chore: fix kv-store browser tests hangs (#22721)
feat: kv-store sqlite backend with page level encryption (#22759)
fix: install node 22 for aztec-cli acceptance test (#22917)
feat: backport kv-store sqlite encryption (#22759) to v4-next (#22927)
fix(docs): correct llms.txt links for versioned developer docs (#22819)
feat(docs): improve discoverability of Aztec.nr API reference docs
(#22861)
feat(docs): backport improve discoverability of Aztec.nr API reference
docs (#22861) to v4-next (#22931)
feat(aztec-nr): add call_self stubs for utility functions (#22885)
docs: add map and state variable docs (backport #22824) (#22880)
refactor: `getPackageVersion` fn cleanup (#22941)
fix(ci): skip acceptance test for canary -commit. tags (#22951)
fix: closing db, correct stub side effects (#22939)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants